package com.ruoyi.bussiness.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.CcyAccountCofig;
import com.ruoyi.bussiness.service.ICcyAccountCofigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账号配置Controller
 * 
 * @author wzy
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/bussiness/cofig")
public class CcyAccountCofigController extends BaseController
{
    @Autowired
    private ICcyAccountCofigService ccyAccountCofigService;

    /**
     * 查询账号配置列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcyAccountCofig ccyAccountCofig)
    {
        startPage();
        List<CcyAccountCofig> list = ccyAccountCofigService.selectCcyAccountCofigList(ccyAccountCofig);
        return getDataTable(list);
    }

    /**
     * 导出账号配置列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:export')")
    @Log(title = "账号配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcyAccountCofig ccyAccountCofig)
    {
        List<CcyAccountCofig> list = ccyAccountCofigService.selectCcyAccountCofigList(ccyAccountCofig);
        ExcelUtil<CcyAccountCofig> util = new ExcelUtil<CcyAccountCofig>(CcyAccountCofig.class);
        util.exportExcel(response, list, "账号配置数据");
    }

    /**
     * 获取账号配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccyAccountCofigService.selectCcyAccountCofigById(id));
    }

    /**
     * 新增账号配置
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:add')")
    @Log(title = "账号配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcyAccountCofig ccyAccountCofig)
    {
        return toAjax(ccyAccountCofigService.insertCcyAccountCofig(ccyAccountCofig));
    }

    /**
     * 修改账号配置
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:edit')")
    @Log(title = "账号配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcyAccountCofig ccyAccountCofig)
    {
        return toAjax(ccyAccountCofigService.updateCcyAccountCofig(ccyAccountCofig));
    }

    /**
     * 删除账号配置
     */
    @PreAuthorize("@ss.hasPermi('bussiness:cofig:remove')")
    @Log(title = "账号配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccyAccountCofigService.deleteCcyAccountCofigByIds(ids));
    }
}
